import 'babel-polyfill'
import Vue from 'vue'
import ElementUI from 'element-ui'
import locale from 'element-ui/lib/locale/lang/zh-CN'

import App from './App'
import router from './router'
import store from './store'

import '@/styles/index.scss' // global css
import '@/icons' // icon
import '@/permission' // permission control

Vue.use(ElementUI, { locale })

Vue.config.productionTip = false

Vue.filter('date', val => {
  if (!val) {
    return ''
  }

  var value = new Date(val)
  var year = value.getFullYear()
  var pad = num => num >= 10 ? num : '0' + num
  if (!isNaN(year)) {
    var month = value.getMonth() + 1
    var day = value.getDate()
    var hour = value.getHours()
    var minutes = value.getMinutes()
    var seconds = value.getSeconds()
    return year + '-' + pad(month) + '-' + pad(day) + ' ' + pad(hour) + ':' + pad(minutes) + ':' + pad(seconds)
  } else {
    return ''
  }
})

new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
